package com.zoe.wan.android.example.repositry

import com.zoe.wan.android.example.repositry.data.home.HomeBannerData
import com.zoe.wan.android.example.repositry.data.home.HomeListData
import com.zoe.wan.android.example.repositry.data.knowledge.KnowledgeDetialData
import com.zoe.wan.android.example.repositry.data.knowledge.KnowledgeListData
import com.zoe.wan.android.example.repositry.data.login.UserData
import com.zoe.wan.android.http.ApiAddress.Article_List
import com.zoe.wan.android.http.ApiAddress.Collect
import com.zoe.wan.android.http.ApiAddress.Home_Banner
import com.zoe.wan.android.http.ApiAddress.Knowledge_List
import com.zoe.wan.android.http.ApiAddress.Knowledge_List_detail
import com.zoe.wan.android.http.ApiAddress.Login
import com.zoe.wan.android.http.ApiAddress.Logout
import com.zoe.wan.android.http.ApiAddress.Register
import com.zoe.wan.android.http.BaseResponse
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query

interface ApiService {

    /// 获取首页列表数据
    @GET(Article_List + "{pageCount}/json")
    suspend fun homeList(@Path("pageCount") pageCount: String): BaseResponse<HomeListData>?


    ///  首页banner
    @GET(Home_Banner)
    suspend fun homeBannerListData(): BaseResponse<HomeBannerData>?

    ///  首页banner
    @FormUrlEncoded
    @POST(Login)
    suspend fun login(
        @Field("username") userName: String,
        @Field("password") password: String
    ): BaseResponse<UserData>?

    @FormUrlEncoded
    @POST(Register)
    suspend fun register(
        @Field("userName") userName: String,
        @Field("password") password: String,
        @Field("repassword") repassword: String
    ): BaseResponse<UserData>?


    @GET(Logout)
    suspend fun logout(): BaseResponse<Any>?

    // 收藏文章
    @POST("$Collect{id}/json")
    suspend fun collect(@Path("id") id: String): BaseResponse<Any>?


    @GET(Knowledge_List)
    suspend fun knowledgeList(): BaseResponse<KnowledgeListData>?


    @GET("$Knowledge_List_detail{pageCount}/json")
    suspend fun knowledgeListDetail(
        @Path("pageCount") pageCount: String = "0",
        @Query("cid") cid: String
    ): BaseResponse<KnowledgeDetialData>?
}